home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / datecls.exe / DATECLS4.DOC < prev    next >
Encoding:
Text File  |  1993-03-07  |  14.8 KB  |  349 lines

  1. =======================================================
  2. Documentation for "The Killer Date Class!" Version 4.00
  3. =======================================================
  4.  
  5. History
  6. =======
  7. In the beginning Steve Marcus (CIS 72007,1233) posted a basic date
  8. manipulation/arithmetic class produced with Borland C++ 2.0 in the 
  9. BPROGB forum, with a request for suggestions and enhancements. This was
  10. on 6/19/91.
  11.  
  12. A rather enterprising gentleman by the name of Eric Simon (CIS 70540,1522)
  13. accepted the challenge, and produced a new and improved version in the 
  14. course of a project he was developing at work. He contributed the results
  15. to the forum on 6/29/91, also inviting enhancements and comments.
  16.  
  17. About that time yet another enterprising gentleman named Christopher Hill
  18. developed a need for a universal date conversion routine for use in a
  19. business project he was developing as well.  Browsing the same forum, he
  20. encountered Eric's class, which provided much of the functionality he needed
  21. - the basic julian-gregorian and day of week conversion algorithms -
  22. relieving him of the task of researching or re-inventing them. Eric had also
  23. added overloaded + and - operators for incrementing date objects by integer
  24. days, as well as several print functions.  Chris needed additional features
  25. for his implementations, thus was born versions 3.0 and 3.1(Hill & Simon).
  26.  
  27. Well, almost a year later I sent out an SOS for a date class so _I_ didn't
  28. have to re-invent the wheel and lo-and-behold Chris responded.  Thus begins
  29. the saga of version 4.0!  I would like to take this opportunity to do a
  30. little witnessing: I looked all over for a date class that would suit my
  31. needs!  I reviewed many implementations from strangers and friends alike
  32. and I am here to tell ya' folks, "It don't 'git no bedder 'n dis!"  This
  33. class is _VERY_ cool!  Now I'm not trying to say that there's no more
  34. room for enhancements (I'd really be crazy then!), but I am saying that if
  35. your looking for a _GOOD_ date class (I'd say commercial quality because
  36. I have yet to see a commercial product that implemented a date class to
  37. my satisfaction!) then this is it!  So jump in and add to it, make it
  38. better and we'll SAVE THE WORLD!  (Ok, so I got a little carried away at
  39. the end. Just a little...)
  40.  
  41. No, but really...
  42. This is a truly pleasing example of co-operation among professionals, and
  43. an "object" study in the code reusability of OOP, resulting in three releases
  44. of one class within a single month by three different analysts who have never
  45. met, and yet another upgrade almost a year later by a fourth analyst (myself)
  46. and none of us have yet to meet!  Chris thanks Steve and Eric for their
  47. inspiration and generousity, and I thank all three as well and hereby
  48. contribute my additions to the public domain.
  49.  
  50. I believe any of us would welcome further comments, suggestions and
  51. enhancements as well.
  52. Good luck!  May the quest for the perfect date class continue!
  53.  
  54.    v4.1  Kenneth A. Argo  - 71241,3635   3/7/93
  55.    v4.0  Charles Price    - 70541,3651   6/27/92
  56.    v3.1  Hill & Simon     -              8/05/91
  57.    v3.0  Christopher Hill - 72030,2606   7/11/91
  58.    v2.0  Eric Simon       - 70540,1522   6/29/91
  59.    v1.0  Steve Marcus     - 72007,1233   6/16/91
  60.  
  61.  
  62. Implementation Notes
  63. ====================
  64.    All versions prior to 4.0 were written specifically for a Borland C++
  65.    compiler.  However, version 4.0 was written specifically for
  66.    Microsoft C++ 7.0.  I too have attempted to optimize the code including
  67.    the specification of const where applicable, the passing of references
  68.    where advisable, and the use of constructor initializers where needed.
  69.    However, I have not made an exhaustive analysis of this subject either.
  70.  
  71.    To get the best overview of the class capabilities run the demo program.
  72.    It may not look pretty, but with a printout of a sample run and the code
  73.    you should be able to get a really good feel for it.  I have included a
  74.    samples run at the end of this file in case someone doesn't want to
  75.    take the time to compile the demo program.
  76.  
  77.    This ZIP file contains:
  78.  
  79.       DATECLS4.DOC   -   this file
  80.       DATECLS4.H     -   the header file
  81.       DATECLS4.CPP   -   the member functions
  82.       DATEDEMO.CPP   -   a test program (and a messy one at that!)
  83.       DATECLS4.LIB   -   a lib file so you can use it even if you
  84.              don't have MSC7.0, or you just don't feel
  85.              like fussin' with it!  (Added in v4.0)
  86.  
  87.  
  88. Future possibilities for enhancement include
  89. ============================================
  90.     
  91.    1. Adding a derived Time class, for those applications which require
  92.       the ability to track more than just dates. This would allow the
  93.       manipulation of times for all dates (not just since 1980), and
  94.       arithmetic calculations as well.
  95.  
  96.  
  97. Additions/Changes to Version 4.1
  98. ================================
  99.  
  100. Fixed date display when using the * operator to get a string pointer.
  101.   The code would return xx/xx/  xx if you only supplied a 2 digit year.
  102. Optimized the * operator so Invalid Dates would use a common "invalid date"
  103.   text pointer.
  104. Fixed the +, - and * operators to get rid cases where memory leaks would
  105.  occur.
  106. Fixed some variable casts so the code can be compiled with /W4
  107. Added a destructor tp delete items created dynamically on behalf of the
  108.  object (ie. char *).
  109.  
  110. Release Documentation for Version 4.0
  111. =====================================
  112. Most of the modifications made to version 3.1 were to expand the public
  113. interface.  Below is a list of new features in v4.0:
  114.  
  115.     1. Date &Set() - Sets self to current system date; this may also be
  116.          accomplished by passing initializing a date object like so:
  117.          Date oDate1("Today");  // See demo for examples
  118.  
  119.     2. Date &Set(long lJulian) - Sets self to the specified julian date
  120.  
  121.     3. Date &Set(int nMonth, int nDay, int nYear) - Sets self to specified
  122.          month, day, and year.  The year must be 4 numbers long, not 2.
  123.  
  124.     4. Date &AddWeeks(int nCount = 1) - Add or subtract(use a negative int)
  125.          a specified number of weeks to/from self
  126.  
  127.     5. Date &AddMonths(int nCount = 1) - Add or subtract(use a negative int)
  128.          a specified number of months to/from self
  129.  
  130.     6. Date &AddYears(int nCount = 1); - Add or subtract(use a negative int)
  131.          a specified number of years to/from self
  132.  
  133.     7. int   Day() const - Returns numeric day of the month for self
  134.     8. int   DaysInMonth() - Returns number of days in month (1..31)
  135.     9. int   FirstDOM() const - Returns the First Day Of Month for self as a
  136.          numeric (1..7)
  137.  
  138.    10. char *CDOW() - Returns character Day Of Week ('Sunday'..'Saturday')
  139.    11. int   NDOW() const - Returns the numeric day of the week for self(1..7)
  140.  
  141.    12. int   WOM() - Returns numeric Week Of Month  (1..6)
  142.    13. int   WOY() - Returns numeric Week Of Year   (1..52)
  143.  
  144.    14. char *CMonth() - Character Month name ("January")
  145.    15. int   NMonth() const - Month Number (1..12)
  146.  
  147.    16. Date  BOM() - Returns a new date object that is the First Date Of
  148.          the Month in self.  For example:
  149.         Date oDate1;
  150.         Date oDate2("Today");
  151.         oDate1 = oDate2.BOM();
  152.  
  153.    17. Date  EOM() - Returns a new date object that is the Last Date Of
  154.          the Month in self.  (See example in 16 above)
  155.  
  156.    18. int   NYear4() const - Returns the numeric value of the year for self
  157.          in the form 1992.
  158.  
  159.    19. Date  BOY() - Returns a new date object that is the First Date Of
  160.          the Year in self. (See example 16 above)
  161.  
  162.    20. Date  EOY() - Returns a new date object that is the Last Date Of
  163.          the Year in self. (See example 16 above)
  164.  
  165.    21. Added overloaded operators for + and - to accept int's.
  166.    22. Added overloaded operators for ++ and -- for Postfix notation
  167.  
  168.    23. Switched from the Borland style DOS date structure(date) to the
  169.        Microsoft version(_dosdate_t).
  170.  
  171. Suggestions and general comments are always welcome!
  172. Enjoy!  Chuck :-}
  173.  
  174.  
  175.  
  176. Release Documentation for Version 3.1
  177. =====================================
  178. Subsequent to release 3.00, we (Hill & Simon) decided to collaborate on
  179. several further releases of this date class. This, the first, contains two
  180. new features, as well as a few minor bug fixes.
  181.  
  182. 1. There was a minor bug in the original Computer Language julian/gregorian
  183.    date conversion routines having to do with negative years.
  184.  
  185. 2. The isLeapYear function did not take into account that, prior to 1582,
  186.    years ending in 00 were also leap years.
  187.  
  188. 3. The two-dimensional array of the number of days in each month has been
  189.    eliminated in favor of a computational approach.
  190.  
  191. 4. The function Date::setFormat(XXXX) maintains a static variable (one
  192.    occurance for all Date objects, which controls the format which the
  193.    << operator uses to print objects. "XXXX" can be MONTH, MDY, DAY, FULL,
  194.    or EUROPEAN.  The setting defaults to MDY, but once altered, remains
  195.    altered until reset by another call to setFormat.
  196.  
  197.    The function Date::setOption(Option, Action) maintains a similar static
  198.    variable which enables certain print formatting options. Available options
  199.    at this point are:
  200.       NO_CENTURY  --  Suppress the printing of the century when
  201.               in the MDY format (ex: 01/01/91 instead of
  202.               01/01/1991).
  203.  
  204.       DATE_ABBR   --  Abbreviate month and day names when printing
  205.               in the MONTH, DAY, FULL or EUROPEAN formats.
  206.               (ex. MON, TUE, JAN, FEB, etc.) The length
  207.               or the abbreviation is controlled by a
  208.               DEFINED constant in DATECL31.HPP named
  209.               ABBR_LENGTH, preset to 3.
  210.  
  211.    "Action" is either ON or OFF, and defaults to ON. (Example, the call
  212.    Date::setOption(NO_CENTURY) turns on the century suppression option, and
  213.    it remains set until the call Date::setOption(NO_CENTURY, OFF) is made.
  214.  
  215.    More features, including further expanded print formatting features,
  216.    the derived Time class mentioned above, conversion into various calendar
  217.    formats (Jewish, Chinese, Arabic, etc.), ability to increment Date objects
  218.    by years and months instead of merely days, holiday computations, and more
  219.    are planned.
  220.  
  221.  
  222. Sample run of DATEDEMO.EXE v4.0
  223. ===============================
  224.  
  225.  Date Class v4.0 Demo 
  226.  
  227. Saturday, October 20, 1962
  228. Monday
  229. Tuesday, October 10, 1995
  230. Tuesday, October 30, 1962
  231. 5 October 1962
  232. -14
  233. 8/6/1991
  234. Tommorrow= Sunday, July 14, 1991
  235. a1 (7-14-91) < 8-01-91 ? ==> TRUE
  236. a1 (7-14-91) > 8-01-91 ? ==> FALSE
  237. a1 (7-14-91)== 7-14-91 ? ==> TRUE
  238. a1 (7-14-91)== a3 (7-14-91) ? ==> TRUE
  239. a1 (7-14-91)== a4 (7-15-91) ? ==> FALSE
  240. Today is: 6/28/1992
  241. Today (a4) is: 6/28/1992
  242. Today + 4 is: 7/2/1992
  243. Today - 4 is: 6/24/1992
  244. =========== Leap Year Test ===========
  245. Wednesday, January 15, 1992     Leap    day of year:  15
  246. Tuesday, February 16, 1993      non-Leap        day of year:  47
  247. =========== eom test ==============
  248. b1.eom() (s/b 2/28/91) ==> 2/28/1991
  249. ================== getDate test =====================
  250. a1.getDate()  (s/b 2/16/1993) ==> 2/16/1993
  251. ================== string assignment test ====================
  252. a1 as a string (s/b 2/16/1993) ==> 2/16/1993
  253. ================== setFormat test ============================
  254. a1 (s/b FULL format) ==> Tuesday, February 16, 1993
  255. a1 (s/b EUROPEAN format) ==> 16 February 1993
  256. ================== setOption test ============================
  257. Date abbreviation ON
  258. a1 (s/b MONTH format) ==> Feb
  259. a1 (s/b DAY format) ==> Tue
  260. a1 (s/b FULL format) ==> Tue, Feb 16, 1993
  261. a1 (s/b EUROPEAN format) ==> 16 Feb 1993
  262. Century suppression ON
  263. a1 (s/b MDY format) ==> 2/16/93
  264. Century suppression OFF
  265. a1 (s/b MDY format) ==> 2/16/1993
  266. Century suppression ON
  267. a1 (s/b MDY format) ==> 2/16/93
  268. a1 (s/b FULL format) ==> Tue, Feb 16, 1993
  269.  
  270. =============== Version 4.0 Enhancement Test =================
  271.  
  272. ---------- Set Stuff -----------
  273. First, 'Set' to today...
  274. Before 'Set' => Saturday, November 26, 1966
  275. After  'Set' => Sunday, June 28, 1992
  276.  
  277. Set to 11/26/66 => Saturday, November 26, 1966
  278. Current Julian  => 2439455
  279. Set to Julian 2450000L => Tuesday, October 10, 1995
  280. See! => 2450000
  281. ---------- Add Stuff -----------
  282. Start => Tuesday, October 10, 1995
  283. Add 4 Weeks => Tuesday, November 7, 1995
  284. Sub 1 Month => Saturday, October 7, 1995
  285. Add 2 Years => Tuesday, October 7, 1997
  286. ---------- Misc Stuff -----------
  287. The date aboves' day of the month is => 7
  288. There are 31 days in this month.
  289. The first day of this month lands on 4
  290. This day happens to be Tuesday
  291. the 3 day of the week,
  292. on the 41 week of the year,
  293. on the 2 week of the month, 
  294. (which is October)
  295. the 10nth month in the year.
  296. The year alone is 1997
  297. ---------- First and Last Stuff -----------
  298. The first date of this month is Monday, June 1, 1992
  299. The last date of this month is Tuesday, June 30, 1992
  300. The first date of this year is Wednesday, January 1, 1992
  301. The last date of this year is Thursday, December 31, 1992
  302.  
  303.  
  304.  
  305.          ----------------end-of-author's-documentation---------------
  306.  
  307.                          Software Library Information:
  308.  
  309.                     This disk copy provided as a service of
  310.  
  311.                            Public (software) Library
  312.  
  313.          We are not the authors of this program, nor are we associated
  314.          with the author in any way other than as a distributor of the
  315.          program in accordance with the author's terms of distribution.
  316.  
  317.          Please direct shareware payments and specific questions about
  318.          this program to the author of the program, whose name appears
  319.          elsewhere in  this documentation. If you have trouble getting
  320.          in touch with the author,  we will do whatever we can to help
  321.          you with your questions. All programs have been tested and do
  322.          run.  To report problems,  please use the form that is in the
  323.          file PROBLEM.DOC on many of our disks or in other written for-
  324.          mat with screen printouts, if possible.  PsL cannot debug pro-
  325.          programs over the telephone, though we can answer questions.
  326.  
  327.          Disks in the PsL are updated  monthly,  so if you did not get
  328.          this disk directly from the PsL, you should be aware that the
  329.          files in this set may no longer be the current versions. Also,
  330.          if you got this disk from another vendor and are having prob-
  331.          lems,  be aware that  some files may have become corrupted or
  332.          lost by that vendor. Get a current, working disk from PsL.
  333.  
  334.          For a copy of the latest monthly software library newsletter
  335.          and a list of the 4,000+ disks in the library, call or write
  336.  
  337.                            Public (software) Library
  338.                                P.O.Box 35705 - F
  339.                             Houston, TX 77235-5705
  340.  
  341.                                 1-800-2424-PSL
  342.                              MC/Visa/AmEx/Discover
  343.  
  344.                           Outside of U.S. or in Texas
  345.                           or for general information,
  346.                               Call 1-713-524-6394
  347.  
  348.  
  349.